package com.num2.controller.lkw;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.num2.form.lkw.Deposit_Money;
import com.num2.form.lkw.Withdraw_Money;
import com.num2.service.lkw.TransferService;

@Controller

public class TransferCtrl {
	@Resource
	private TransferService transferservice;
	@RequestMapping("/transfer")
	public String transferMoney(String user_name,String income_expend,HttpSession session,Model m){
		Withdraw_Money wm = new Withdraw_Money();
//		wm.setUser_name(user_name);
		wm.setIncome_expend(income_expend);
		Deposit_Money dm = new Deposit_Money();
		dm.setIncome_expend(income_expend);
		dm.setUser_name(user_name);
		boolean result = transferservice.transMoney(dm,wm,session);
		if(result){
			m.addAttribute("success","转账成功!");
			return "demo/transfer";
		}else{
			m.addAttribute("fail","转账失败!可能原因：①转账金额不为数字;②对方账户不存在;③对方账户为自己的账户!");
			return "demo/transfer";
		}
	}
	public TransferService getTransferservice() {
		return transferservice;
	}
	public void setTransferservice(TransferService transferservice) {
		this.transferservice = transferservice;
	}
	
}
